package com.ficv.tucanalmovil.web;



import java.io.IOException;

import javax.annotation.PostConstruct;
import javax.mail.MessagingException;
import javax.mail.internet.MimeMessage;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.integration.Message;
import org.springframework.integration.channel.DirectChannel;
import org.springframework.integration.core.MessageHandler;


public class MailReader {
	private static final Logger logger = LoggerFactory.getLogger(MailReader.class);
	
//	@Autowired
//	DirectChannel inputChannel;
//	
//	@PostConstruct
//	void subscribe() {
//		inputChannel.subscribe(new MessageHandler() {
//
//
//			public void handleMessage(Message<?> message) {
//				logger.info("Message: " + message);
//			}
//		});
//	}
	
	public void receive(MimeMessage mimeMessage) throws IOException, MessagingException {
		logger.info("Message: " + ((javax.mail.internet.MimeMultipart)mimeMessage.getContent()).getBodyPart(0).getContent());
		String text=((javax.mail.internet.MimeMultipart)mimeMessage.getContent()).getBodyPart(0).getContent().toString();
//		String code=text.substr(text.indexOf("__findMeCode:"));
//		String text=text.indexOf("Desde: ");
	}
	
	
}
